/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package caintra.Sapra.ComponentsImplements;

import caintra.Sapra.Pantalla.Ajuste.Pantalla_Mensaje;
import java.util.Locale;
import java.util.ResourceBundle;
import nextapp.echo2.app.Color;
import nextapp.echo2.app.ContentPane;
import nextapp.echo2.app.Extent;
import nextapp.echo2.app.FillImageBorder;
import nextapp.echo2.app.Insets;
import nextapp.echo2.app.WindowPane;
import nextapp.echo2.app.event.WindowPaneEvent;
import nextapp.echo2.app.event.WindowPaneListener;

/**
 *
 * @author Administrador
 *
 *
 */
public class WindowCaintra extends WindowPane{


    public ResourceBundle bundle = ResourceBundle.getBundle("caintra.Sapra.Internacional.MessageBundle",Locale.US);

    public WindowCaintra(String title,int posX,int posY,int width,int height){
            FillImageBorder fi=new FillImageBorder();
            fi.setColor(Color.BLUE);
            fi.setBorderInsets(new Insets(2));
            fi.setContentInsets(new Insets(8));
            this.setBorder(fi);
            this.setWidth(new Extent(width));
            this.setHeight(new Extent(height));
            this.setPositionX(new Extent(posX));
            this.setPositionY(new Extent(posY));
            this.setModal(true);
            this.setVisible(false);
            this.setTitleHeight(new Extent(23));
            this.setTitleBackground(new Color(60,70,140));
            this.setResizable(true);
            this.setMovable(true);
            this.setBackground(new Color(220,220,255));
            this.setClosable(true);

            if(bundle.containsKey(title.trim())){
                this.setTitle(bundle.getString(title.trim()));
            }else{
                this.setTitle(title);
            }
            this.setDefaultCloseOperation(HIDE_ON_CLOSE);
        
    }

    public void setContentPane(ContentPane cp){
        try {
                this.removeAll();
                this.setModal(true);
                this.setVisible(true);
                this.add(cp);
            
        } catch (Exception e) {
        }

    }
    public CalendarPane panel;
    public void setContentPane(CalendarPane panel){
        try {
            this.panel=panel;
            this.removeAll();
                this.setModal(true);
                this.setVisible(true);
                this.add(panel);
                this.addWindowPaneListener(new WindowPaneListener() {

                public void windowPaneClosing(WindowPaneEvent e) {
                    ejecutar_fecha();
                }
            });
        } catch (Exception e) {
        }

    }
    public void ejecutar_fecha(){
        this.panel.exit_on_close();
    }

    public Pantalla_Mensaje pm;

    public void setContentMessage(Pantalla_Mensaje pm){
        try {
                this.pm = pm;
                this.removeAll();
                this.setModal(true);
                this.setVisible(true);
                this.add(pm);
        } catch (Exception e) {
        }

    }

    public void mensaje_Panel(String msj){
        pm.setMsj(msj);
    }


    public void setTitle_Window(String title){
        try {
            if(bundle.containsKey(title.trim())){
                this.setTitle(bundle.getString(title.trim()));
            }else{
                this.setTitle(title);
            }
        } catch (Exception e) {
            this.setTitle("");
        }
    }
    /*
    @Override
    public void setDefaultCloseOperation(int newValue) {
        if(newValue==10){
            this.setModal(false);
            this.setVisible(false);
            this.removeAll();
           

        }

    }
   */

}


